/*
 * @Description: 上传资源文件组件，返回文件连接
 * @Author: Rfan
 * @Date: 2022-02-28 15:39:05
 * @LastEditTime: 2022-03-01 09:41:22
 */

import { Button, Upload } from 'antd';
import React, { useState } from 'react';

const UploadFile = (props: any) => {
  // const { files } = props;
  const [uploadList, setUploadList] = useState<File[]>([]);

  const beforeUpload = (file: File) => {
    setUploadList((state) => [...state, file]);
    // return false;
  };

  const UploadSelectorFunc = (data: any) => {
    console.log('upload', data, uploadList);
    // const formData = new FormData();
    // formData.append('files', [data.file]);
    // action="http://127.0.0.1:8080/uploads"
  };

  return (
    <Upload beforeUpload={beforeUpload} customRequest={UploadSelectorFunc} fileList={[]} multiple>
      <Button type="primary">选取本地文件</Button>
    </Upload>
  );
};

export default UploadFile;
